﻿using ProjScan.RecordManager;
using ProjScan.RecordManager.AssetData;
using ProjScan.ScanRule.Attr;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.ScanRule.ProjectAssets.Material
{
    [MaterialRuleAttr]
    internal class Mat_PureColorTex : RecordRuleImp<MaterialAssetData, MaterialRecordManager>
    {
        protected override bool IsOK(MaterialAssetData assetData)
        {
            bool flag = false;
            MaterialProperty[] materialProperties = assetData.MaterialProperties;
            foreach (MaterialProperty materialProperty in materialProperties)
            {
                UnityEngine.Texture2D texture2D = materialProperty.textureValue as UnityEngine.Texture2D;
                if (texture2D != null && texture2D.width > 0 && texture2D.height > 0 && ToolsHelper.IsAllSameColorAsCenter(ToolsHelper.PixelArrayFromTexture2D(texture2D), texture2D.width, texture2D.height))
                {
                    flag = true;
                }
            }

            return !flag;
        }
    }
}